package com.jdjw.modules.buscomment.controller;


import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jdjw.common.ResponseResult;
import com.jdjw.modules.buscomment.entity.BusComment;
import com.jdjw.modules.buscomment.entity.QueryEntity;
import com.jdjw.modules.buscomment.service.BusCommentService;
import com.jdjw.modules.buscommentjcllzzfw.entity.BusCommentJcllzzfw;
import com.jdjw.modules.buscommentjcllzzfw.service.BusCommentJcllzzfwService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.thymeleaf.util.StringUtils;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.Wrapper;
import java.util.Map;

/**
 * <p>
 * 项目评价表 前端控制器
 * </p>
 *
 * @author fq
 * @since 2021-05-28
 */
@RestController
@RequestMapping("/buscomment")
public class BusCommentController {

    @Resource
    BusCommentService busCommentService;
    @Resource
    BusCommentJcllzzfwService busCommentJcllzzfwService;

    @ApiOperation("处置结果反馈")
    @PostMapping("{id}/resultFeedback")
    public ResponseResult resultFeedback(@ApiParam(value = "处置数据id", required = true) @PathVariable("id") String id,
                                         QueryEntity queryEntity) {
        BusComment retComment = busCommentService.getById(id);
        if (ObjectUtil.isNotNull(retComment)){
            BusComment comment = new BusComment();
            comment.setId(id);
            comment.setReplier(queryEntity.getReplier());
            comment.setRecoveryDate(queryEntity.getRecoveryDate());
            comment.setReplierText(queryEntity.getReplierText());
            comment.setUrge("政法委平台已处置");
            comment.setDealResult("2");//状态改为已处置
            return busCommentService.resultFeedback(comment);
        }

//        QueryWrapper<BusCommentJcllzzfw> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("report_id",id);
        BusCommentJcllzzfw retCommentJcllzzfw = busCommentJcllzzfwService.getById(id);
        if (ObjectUtil.isNotNull(retCommentJcllzzfw)){
            BusCommentJcllzzfw commentJcllzzfw = new BusCommentJcllzzfw();
            commentJcllzzfw.setId(retCommentJcllzzfw.getId());
            commentJcllzzfw.setReplier(queryEntity.getReplier());
            commentJcllzzfw.setRecoveryDate(queryEntity.getRecoveryDate());
            commentJcllzzfw.setReplierText(queryEntity.getReplierText());
            commentJcllzzfw.setUrge("政法委平台已处置");
            commentJcllzzfw.setDealResult("2");//状态改为已处置
            return busCommentJcllzzfwService.resultFeedback(commentJcllzzfw);
        }

        ResponseResult result = new ResponseResult();
        result.setCode(500);
        result.setMsg("ERROR");
        result.setData("该数据不存在或原数据丢失");
        return result;
    }

}

